﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using CE.Provider;
public partial class controls_usrScrollingCompanyLogoByServices : System.Web.UI.UserControl
{
    //    100	Car Insurance
    //    200	Home Refinance
    //    300	Credit Card
    //    400	Personal Loan
    //    500	Personal Accident
    //    600	Travel Insurance
    //private string strProviderTypeId;
    private int intlimitCount;
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public int LogoLimitCount
    {
        get { return intlimitCount; }
        set { intlimitCount = value; }
    }

    protected override void OnPreRender(EventArgs e)
    {
        if (intlimitCount < 6)
        {
            intlimitCount = 6;
        }

        LoadProviderLogo();
    }

    private void LoadProviderLogo()
    {
        CompanyLogo _companylogo = new CompanyLogo();
        CompanyDB _companydb = new CompanyDB();
        ProviderCompanyServicesList _pserviceslist = new ProviderCompanyServicesList();
        ProviderCompanyServicesDB _pservicesdb = new ProviderCompanyServicesDB();
        _pserviceslist = _pservicesdb.GetProviderCompanyServicesListGroupBy();

        int _count = 0;
        
        if (_pserviceslist != null)
        {
            foreach (ProviderCompanyServices _pservices in _pserviceslist)
            {

                Image imgCompanyLogo = new Image();
                _companylogo = _companydb.GetCompanyScrollingLogo(_pservices.ProviderCompanyId);
                if (_companylogo.CompanyScrollingLogoUrl != string.Empty)
                {
                    imgCompanyLogo.ImageUrl = _companylogo.CompanyScrollingLogoUrl;
                    imgCompanyLogo.AlternateText = _companylogo.CompanyName;
                    imgCompanyLogo.ToolTip = _companylogo.CompanyName;
                    imgCompanyLogo.Width = Unit.Pixel(90);
                    imgCompanyLogo.Height = Unit.Pixel(48);
                    if (_count < 6)
                    {
                        divImgList1.Controls.Add(imgCompanyLogo);
                        if (_pserviceslist.Count < 6)
                        {
                            divImgList2.Controls.Add(imgCompanyLogo);
                        }
                    }
                    else if (_count >= 6 && _count < 12)
                    {
                        divImgList2.Controls.Add(imgCompanyLogo);
                    }

                    _count++;
                    if (_count >= intlimitCount)
                    {
                        break;
                    }
                }
                //if (_count == 1)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo1.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 2)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo2.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 3)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo3.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 4)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo4.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 5)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo5.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
                //else if (_count == 6)
                //{
                //    _companylogo = _companydb.GetCompanyLogo(_pservices.ProviderCompanyId);
                //    imgCompanyLogo6.ImageUrl = _companylogo.CompanyLogoServerUrl;
                //}
            }
        }
    }
}
